Repository navigation
feat(bin): add pr=batch registry token to ship branches through a project's batch script - #4
Merged
Merged
Conversation
A project that batches its finished branches into one pull request at a time with its own scripts/batch.sh is registered with pr=batch. Workers on no-mistakes skip the pipeline's pr and ci steps so it only validates and pushes, direct-PR workers push without opening a PR, and both then run scripts/batch.sh ship and report the shared batch PR once it is green or merged. Several tasks record the same pr= and land when it merges. A queued branch declares a wait, a failing batch is reported as a blocker and fixed forward by a separate task cut from the batch with --base-branch, and a batched branch is never rewritten. The ship-landing skill says how firstmate resumes those workers.
…cate pr=batch tests
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Intent
Make firstmate ship keyse/Warka branches through Warka's own per-user batching script (scripts/batch.sh) instead of one PR per branch. Add a new value pr=batch to the existing pr= registry token in data/projects.md (beside pr=manual). It is accepted on no-mistakes, no-mistakes-prod-only and direct-PR projects, and refused on local-only (nothing to ship into) and beside any forge= token. Brief, spawn and promote carry it exactly like pr=manual (Delivery contract: mode= pr=batch; spawn refuses drift both ways), but unlike manual it also binds direct-PR tasks so internal-only work is batched too. Worker contract: a no-mistakes worker runs its local gate with --skip pr,ci (review/test/document/lint/push still run); a direct-PR worker pushes its fm/* branch and opens no PR. The worker then waits for the project's branch-check workflow (gh run watch, no bare sleep), runs scripts/batch.sh ship, and reads scripts/batch.sh status: if its branch is in the open batch it watches the batch PR's checks and reports the ordinary CI-ready line 'done: PR checks green' so firstmate's existing pr-check registration, merge poll, yolo merge and teardown all work unchanged with several tasks sharing one batch PR (teardown's landed test passes because batches merge with --no-ff); if queued it appends 'paused: queued for the next batch behind PR ' and stops (parked, not failed); if a batch check fails it appends 'blocked: batch PR failed ...; needs a fix-forward branch cut from scripts/batch.sh base' and stops. A batched branch is never rewritten; failures are fixed forward by a new crew task spawned with --base-branch set to the batch branch. Rule 1 gets a single carve-out letting scripts/batch.sh ship push batch branches, open or extend the batch PR and arm auto-merge; the worker never runs batch.sh subcommands other than status, ship and base. Firstmate itself never runs batch.sh (hard rule 1: no state-changing commands in projects), so the ship-landing skill tells firstmate to steer queued workers one at a time to resume at the ship step when a batch PR merges or closes (that ship opens the next batch), and for a failing batch to dispatch ONE fix-forward ship and then steer blocked workers to resume watching. Docs (docs/configuration.md PR posture selection, project-management skill, README) note batch.automerge should only be set on +yolo projects. Registering Warka with pr=batch is deliberately NOT part of this change: it is applied to the private registry only after this lands, because the running home would refuse the unknown token. This ships to the keyse/firstmate fork only; never to kunchenguid/firstmate upstream. Repo style: one sentence per line in Markdown, plain dash never em dash, no agent co-author.
What Changed
bin/fm-project-mode.shnow acceptspr=batchas a newpr=registry token. It is allowed on no-mistakes, no-mistakes-prod-only and direct-PR projects. It is refused (exit 3) on local-only projects and next to anyforge=token.fm_pr_text_validinbin/fm-dod-lib.shapplies the same rules.fm-brief.sh --pr batch,fm-spawn.shandfm-promote.shcarry the token the same way they carrypr=manual, withDelivery contract: mode=<m> pr=batch. Unlike manual, it also binds direct-PR tasks, and spawn refuses a brief that drifts from the registry in either direction.fm_dod_batch_ship_stepsworker contract inbin/fm-dod-lib.sh:--skip pr,ci. A direct-PR worker pushes its branch and opens no PR.gh run watchand runsscripts/batch.sh ship, then readsscripts/batch.sh status. It reportsdone: PR <batch url> checks greenwhen its branch is in the open batch,paused: queued for the next batch behind PR <url>when it is queued, orblocked: batch PR <url> failed ...when a batch check fails.status,shipandbasesubcommands.scripts/batch.sh shippush batch branches, open or extend the batch PR, and arm auto-merge.--base-branchset to the batch branch.docs/configuration.md, the project-management skill and the README documentpr=batchand note thatbatch.automergebelongs only on+yoloprojects.tests/fm-project-mode.test.shandtests/fm-task-delivery.test.shcover the token's accept/refuse rules and the brief, spawn and promote behavior.🤖 Generated with Claude Code
Risk Assessment
Testing
I drove the real firstmate CLIs (fm-project-mode, fm-brief, fm-spawn, fm-promote) against disposable marked lab homes and fixture git projects, and saved transcripts plus the rendered briefs and promote payloads as evidence. Registry: pr=batch resolves on no-mistakes, no-mistakes-prod-only and direct-PR, and every invalid entry exits 3 with a reason, while --forge still answers. Briefs: both modes record "Delivery contract: mode=<m> pr=batch". The no-mistakes brief has --skip pr,ci only. Both carry the scripts/batch.sh ship exception in rule 1 and the paused, blocked and done lines. A fix-forward --base-branch brief rebases onto and merges from the batch branch. Every invalid combination is refused without writing a brief. Spawn refused drift in both directions and recorded no task. Agreeing briefs passed the pr= check and stopped later only because tmux is not installed, so worker panes were never actually launched. Promote delivered pr=batch plus the carve-out for no-mistakes and direct-PR, and plain local-only when promoted to local-only. Both targeted test files pass. The end-to-end GitHub batch flow (real batch.sh, a batch PR, the merge poll, teardown) was not driven. This change has no UI, so there are no screenshots.Evidence: Registry resolution/refusal transcript
Source: Registry resolution/refusal transcript
Evidence: fm-brief pr=batch scaffold and refusal transcript
Source: fm-brief pr=batch scaffold and refusal transcript
Evidence: Generated no-mistakes pr=batch brief
Source: Generated no-mistakes pr=batch brief
Evidence: fm-spawn drift refusal / agreement transcript
Source: fm-spawn drift refusal / agreement transcript
Evidence: fm-promote transcript
Source: fm-promote transcript
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
.agents/skills/project-management/SKILL.md:64- Part of the intent is missing. The intent says: 'Docs (docs/configuration.md PR posture selection, project-management skill, README) note batch.automerge should only be set on +yolo projects.' Only docs/configuration.md:2407 has that note, and even there it says 'whether a batch pull request is armed for auto-merge' without naming the batch.automerge setting. The new pr=batch line in the project-management skill (.agents/skills/project-management/SKILL.md:64) and the README bullet (README.md:48) say nothing about auto-merge or +yolo. Firstmate could register a non-yolo project with pr=batch, and the project's own auto-merge would then merge batch PRs with no merge authority. Fix: add a one-sentence note in both places, and namebatch.automergein docs/configuration.md..agents/skills/ship-landing/SKILL.md:24- Firstmate's yolo merge would squash a batch PR, but the intent assumes batches merge with --no-ff. The intent says 'yolo merge and teardown all work unchanged ... because batches merge with --no-ff'. On GitHub, bin/fm-pr-merge.sh uses --squash unless the caller names a method (bin/fm-pr-merge.sh:22, :1889-1890). The new ship-landing text only says 'merge it once' and gives no method. Failure case: on a +yolo pr=batch project, task A reports 'done: PR <batch> checks green' and firstmate merges with no method. The batch lands on main as one squash commit, so none of the batched fm/* branches are ancestors of main. Teardown still passes, because pr_is_merged compares against the PR head, not main. But anything in Warka's scripts/batch.sh that decides whether a branch is merged or ready by ancestry on main can see those branches as unmerged and re-batch them on the nextship. The project's own --no-ff history is also lost. Fix: tell firstmate to merge batch PRs withbin/fm-pr-merge.sh <id> <url> -- --merge, or have the merge path pick --merge for pr=batch tasks. Picking the merge method is a product decision, so asking the user.bin/fm-dod-lib.sh:229- For a batched task, bin/fm-review-diff.sh shows the whole batch's diff as that task's change, with no error. The batched worker reports the shared batch PR, so the task's recorded pr= is that PR. fm-review-diff.sh (lines 167-172) always compares against the fetched refs/pull/<n>/head when pr= is set. Failure case: tasks A and B both sit in batch PR fix: keep idle watcher supervision silent kunchenguid/firstmate#10, andfm-review-diff.sh Ashows B's changes and the batch merge commits as A's work. A fix-forward task shows the entire batch. Any review or captain report built from that diff for a pr=batch task covers the wrong content. Fix: compare against the task's own ship branch when the task is batched. Nothing in the task metadata records pr=batch today, so the fix needs a new metadata field or a registry lookup. That remedy is new state, so asking the user.tests/fm-task-delivery.test.sh:1577- The new pr=batch tests were inserted between an existing comment block and the test it describes. That comment ('green checks on a server that has neither ... local-only, which publishes nothing, cannot carry it') belongs to test_spawn_requires_the_brief_to_carry_the_registered_forge. It now sits directly above the pr=batch comment and test_pr_batch_brief_ships_through_the_project_batch, so it describes the wrong test. Fix: move the three new tests above that comment block.🔧 Fix applied.
2 warnings still open:
.agents/skills/ship-landing/SKILL.md:24- Firstmate's yolo merge would squash a batch PR, but the intent assumes batches merge with --no-ff. The intent says 'yolo merge and teardown all work unchanged ... because batches merge with --no-ff'. On GitHub, bin/fm-pr-merge.sh uses --squash unless the caller names a method (bin/fm-pr-merge.sh:22, :1889-1890). The new ship-landing text only says 'merge it once' and gives no method. Failure case: on a +yolo pr=batch project, task A reports 'done: PR <batch> checks green' and firstmate merges with no method. The batch lands on main as one squash commit, so none of the batched fm/* branches are ancestors of main. Teardown still passes, because pr_is_merged compares against the PR head, not main. But anything in Warka's scripts/batch.sh that decides whether a branch is merged or ready by ancestry on main can see those branches as unmerged and re-batch them on the nextship. The project's own --no-ff history is also lost. Fix: tell firstmate to merge batch PRs withbin/fm-pr-merge.sh <id> <url> -- --merge, or have the merge path pick --merge for pr=batch tasks. Picking the merge method is a product decision, so asking the user.bin/fm-dod-lib.sh:229- For a batched task, bin/fm-review-diff.sh shows the whole batch's diff as that task's change, with no error. The batched worker reports the shared batch PR, so the task's recorded pr= is that PR. fm-review-diff.sh (lines 167-172) always compares against the fetched refs/pull/<n>/head when pr= is set. Failure case: tasks A and B both sit in batch PR fix: keep idle watcher supervision silent kunchenguid/firstmate#10, andfm-review-diff.sh Ashows B's changes and the batch merge commits as A's work. A fix-forward task shows the entire batch. Any review or captain report built from that diff for a pr=batch task covers the wrong content. Fix: compare against the task's own ship branch when the task is batched. Nothing in the task metadata records pr=batch today, so the fix needs a new metadata field or a registry lookup. That remedy is new state, so asking the user.✅ **Test** - passed
✅ No issues found.
bin/fm-lab-home.sh create $LABdisposable lab home with a fixture data/projects.md (7 pr=batch entries: valid, local-only, forgejo, gerrit, unknown value)FM_HOME=$LAB bin/fm-project-mode.sh [--pr|--forge] <warka-*>for every entry, recording each exit statusFM_HOME=$LAB bin/fm-brief.sh <id> <proj> --mode no-mistakes|direct-PR --pr batch [--base-branch batch/keyse/3], then refusals for local-only, --forge forgejo, --forge gerrit, --scout, and --pr batchyFM_HOME=$LAB bin/fm-spawn.shin a marked lab home with git fixture projects with file:// origins: drift both ways (registry pr=batch vs brief auto; brief pr=batch vs registry auto), then agreeing direct-PR and no-mistakes+yolo briefsFM_HOME=$LAB bin/fm-promote.sh <scout-id> --mode no-mistakes|direct-PR|local-only --yolo offon a no-mistakes-prod-only pr=batch project, capturing the delivered ship-instructions payloadbash tests/fm-project-mode.test.shbash tests/fm-task-delivery.test.sh(covers the new pr=batch brief, refusal and spawn tests)Checked that the batch.automerge +yolo note appears in README.md, the project-management skill and docs/configuration.md, and that the diff has no em dash✅ **Document** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.